#!/bin/sh

. /etc/rc.d/functions

if [ -f "/etc/sysconfig/OBEXD" ]; then
   . /etc/sysconfig/OBEXD
fi

OBEXD=/usr/lib/bluetooth/obexd
OPT="--auto-accept"

case "${1}" in
   start)
      log_info_msg "Starting Obexd daemon..."
      pidlist=`pidofproc $OBEXD`

      if [  "${?}" = "0" ]; then
        log_info_msg2 " Already running"
        log_success_msg2
        exit 0;
      fi
      # Start as background process and assume OK
      $OBEXD $OPT &
      log_success_msg2
      ;;

   stop)
      log_info_msg "Stopping Obexd daemon..."
      killproc $OBEXD
      evaluate_retval
      ;;

   restart)
      ${0} stop
      sleep 1
      ${0} start
      ;;

   status)
      statusproc $OBEXD
      ;;

   *)
      echo "Usage: ${0} {start|stop|restart|status}"
      exit 1
      ;;
esac

exit 0

# End OBEXD
